
from django import forms
from content.models import Goods

class GoodsSearchForm(forms.ModelForm):
    class Meta:
        model = Goods
        fields = ['name','category']

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            field.widget.attrs = {"class": "layui-input", "placeholder": "请输入" + field.label,}

class GoodsForm(forms.ModelForm):
    class Meta:
        model = Goods
        fields = ['name','category', 'price','rating','description','images']

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            field.widget.attrs = {"class": "layui-input", "placeholder": "请输入" + field.label,}